package com.rico;

import com.rico.aop.MathCalculator;
import com.rico.beans.Car;
import com.rico.beans.ClassRoom;
import com.rico.beans.User;
import com.rico.importanotation.HelloImport;
import com.rico.importanotation.ModelImportSelector;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

@Import({ModelImportSelector.class, HelloImport.class})
@ComponentScan
public class AnnotationConfigApplicationContextApplication {

    public static void main(String args[]) throws Exception {
        ApplicationContext context = new AnnotationConfigApplicationContext("com.rico");

        ClassRoom room=(ClassRoom) context.getBean(ClassRoom.class);
        System.out.println("class room:"+room.getUser().getUserName());
        User user = (User)context.getBean("factoryBeanTest");
        System.out.println(user.getUserName());

        user=(User)context.getBean("user");
        System.out.println(user.getUserName());

        System.out.println( user.getBirthDay());

        MathCalculator mathCalculator = context.getBean(MathCalculator.class);
        //mathCalculator.div(10, 0);


    }
}
